package housing.task1.actor;

import housing.task1.document.Request;
import housing.task1.document.WorkPlan;
import housing.task1.generator.AutoCompleter;
import housing.task1.generator.AutoCompleter.WorkScale;
import housing.task1.generator.AutoCompleter.WorkType;

import javax.xml.bind.annotation.XmlRootElement;
import java.util.GregorianCalendar;

/**
 * Created by IntelliJ IDEA.
 * User: Linderhof
 * Date: 13.11.2010
 * Time: 20:53:38
 * <p/>
 * Contains inforamtion about Flat Renter.
 * The Renter has id, first name, last name and Address(subclass)
 * <p/>
 * Renters are capable of sending requests for their fla repairement
 */

@XmlRootElement(name = "Renter")
public class Renter extends Human {

    private Address _address;

    @Override
    public String toString() {
        return "Renter.xsd: " + get_id() + " " + get_firstName() + " " + get_lastName() + " " +
               get_address().toString();
    }

    @Override
    public void act() {
        sendRequest(WorkType.generateWorkType(),
                WorkScale.generateWorkScale(),
                AutoCompleter.generateDate()
        );
    }

    public Renter() {
        super();
        set_address(Address.randomAddress());
    }

    public Renter(long id, String firstName, String secondName, Address address) {
        set_id(id);
        set_firstName(firstName);
        set_lastName(secondName);
        set_address(address);
    }


    /**
     * Sends request
     *
     * @param w type of the work requested
     * @param s scale of the work requested
     * @param d date
     */
    public void sendRequest(AutoCompleter.WorkType w, AutoCompleter.WorkScale s, GregorianCalendar d) {
        WorkPlan.getInstance().getRequests().add(new Request(this, w, s, d));
    }// void sendRequest()


    public Address get_address() {
        return _address;
    }

    public void set_address(Address _address) {
        this._address = _address;
    }


}//class Renter.xsd

